﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SystemDoc_class_edit.aspx.cs" Inherits="Ccit.OA.SystemDoc.SystemDoc_class_edit" %>
<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>类别新增</title>
    <script language="javascript" type="text/javascript" src="../script/jquery.js"></script>
    <script language="javascript" type="text/javascript" src="../script/StringClass_Ext.js"></script>
    <script language="javascript" type="text/javascript" src="../script/jsonlib.js"></script>
    <script language="javascript" src="../script/jwindow.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jcontrol.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jbase64.js" type="text/javascript"></script>
    <script type="text/javascript">
        function CheckForm()
        { 
            var vnumber = document.getElementById("txtNumber").value;
            if(vnumber.Trim()=="")
            {
                  alert("类别编号不能为空!");
                  document.getElementById("txtNumber").focus();
                  return false;  
            }
            
            var vname = document.getElementById("txtName").value;
            if(vname.Trim()=="")
            {
                  alert("类别名称不能为空!");
                  document.getElementById("txtName").focus();
                  return false;  
            }
            return true;
        }
        function doSave()
        {
             if(!CheckForm()) return;
             var MsSecond = {};
             MsSecond.Sysdocid = document.getElementById("_hidSysDocId").value;
             MsSecond.Superiorid = getDropDownSelValue("ddlUpAddr");
             MsSecond.Sysnumber = document.getElementById("txtNumber").value; 
             MsSecond.Systypename = document.getElementById("txtName").value;
             MsSecond.Managemark = document.getElementById("_hidManageMark").value;
             MsSecond.Manageid = document.getElementById("_hidManageid").value;
             MsSecond.Viewmark = document.getElementById("_hidViewMark").value;
             MsSecond.Viewid = document.getElementById("_hidViewId").value; 
             MsSecond.Primary = document.getElementById("_hidClassType").value;
             
             var Manageupaddr = document.getElementById("chkManageupaddr");
             if(Manageupaddr.checked==true)
             {
                MsSecond.Manageupaddr="1";
             }
             var Managelower = document.getElementById("chkManagelower");
             if(Managelower.checked==true)
             {
                MsSecond.Managelower="1";
             }
             var Viewupaddr = document.getElementById("chkViewupaddr");
             if(Viewupaddr.checked==true)
             {
                MsSecond.Viewupaddr="1";
             }
             var Viewlower = document.getElementById("chkViewlower");
             if(Viewlower.checked==true)
             {
                MsSecond.Viewlower="1";
             }
             var jsonExpr = JSON.stringify(MsSecond,function(key,value){return value;}); 
                      MsSecond = null;
               PageMethods.DoSave(jsonExpr,ClientBack); 
        }
            function ClientBack(vResult)
            {
                 var oXMLDoc = new ActiveXObject("Microsoft.XMLDOM");  
                    oXMLDoc.loadXML(vResult); 
                    var vExeResult = $(oXMLDoc).find("EXERESULT").text();  //result   
                 eval("var resultObj=" + vExeResult);
                    var addrId = resultObj.resultSign;
                    var upAddrId = resultObj.upAddrId;
                    var isAddNew = resultObj.isAddNew;  //是否是新增记录标志  0:是 1:否   
                    
                    alert(resultObj.message); 
                    if(parseInt(addrId) > 0) {
                        $get("_hidSysDocId").value = addrId;
                         var curColObj = {};
                        var NodeTAB =  parent.frames[0].document.getElementById("_hidNodeTab").value;
                        curColObj.Sysdocid = resultObj.resultSign;
                        if(NodeTAB=="1")
                        {
                            resultObj.resultName = document.getElementById("txtNumber").value; 
                        }
                        curColObj.Systypename = resultObj.resultName;
                        curColObj.fstate = "";
                        curColObj.State = resultObj.hasChild
                        var jsonExpr=JSON.stringify(curColObj,function(key,value){return value;});
                        parent.frames[0].document.getElementById("_hidClassType").value=$get("_hidClassType").value;
                        parent.frames[0].document.getElementById("_hidNewColumnId").value=jsonExpr; 
                        parent.frames[0].document.getElementById("_hidSysDocId").value = $get("_hidSysDocId").value; 
                        parent.frames[0].document.getElementById("_hidUpAddrId").value = upAddrId; //此处与获取_hidUpDeptId值应一样              
                        parent.frames[0].document.getElementById("_hidOriUpAddrId").value = $get("_hidSysDocId").value;
                        parent.frames[0].document.getElementById("_hidAddNewSign").value = isAddNew;  //新增记录标志
                        parent.frames[0].document.all.btnTrigger.click();     
                         var Manageupaddr ;
                         if(document.getElementById("chkManageupaddr").checked==true)
                         {
                           Manageupaddr="1";
                         } 
                         if(document.getElementById("chkManagelower").checked==true)
                         {
                            Manageupaddr="1";
                         } 
                         if(document.getElementById("chkViewupaddr").checked==true)
                         {
                            Manageupaddr="1";
                         } 
                         if(document.getElementById("chkViewlower").checked==true)
                         {
                           Manageupaddr="1";
                         }
                        if(Manageupaddr=="1")
                        {__doPostBack("lnbCallBack","");}                      
                       // $get("_hidOriUpAddrId").value = upAddrId;
                    } 
                    resultObj = null;
            }
         function getDropDownSelValue(ctrlId) {
               var ddl = new DropDownList(ctrlId);
               var selValue = ddl.selectedValue;
               ddl = null;
               return selValue;
          }
          function doSelect(otype)
          {             
                var Manageupaddr;   
                if(otype=="0")
                {
                   Manageupaddr = document.getElementById("chkManageupaddr");
                   if(Manageupaddr.checked==true)   
                   {
                        document.getElementById("lnbManage").href="#";                        
                   }
                   else
                   {
                       document.getElementById("lnbManage").href="javascript:doSelUser('_hidManageid','_hidManageMark','txtManage')";                     
                   }
                }
                else
                {
                   Manageupaddr = document.getElementById("chkViewupaddr");
                   if(Manageupaddr.checked==true)   
                   { 
                        document.getElementById("lnbview").href="#";
                   }
                   else
                   {                      
                       document.getElementById("lnbview").href="javascript:doSelUser('_hidViewId','_hidViewMark','txtView')"; 
                   }
                }   
          }
          function doSelUser(vRagneId,vCtrlId,vCtrlName) {
                OpenRangeSelect(vRagneId,vCtrlId,vCtrlName,"1");
          }
          function initializeAddNew(){
                document.getElementById("_hidSysDocId").value="";
                document.getElementById("txtNumber").value="";
                document.getElementById("txtName").value="";
                document.getElementById("txtManage").value="";
                document.getElementById("txtView").value="";
                document.getElementById("_hidManageid").value="";
                document.getElementById("_hidManageMark").value="";
                document.getElementById("_hidViewId").value="";
                document.getElementById("_hidViewMark").value="";
          }
    </script>
</head>
<body>
    <ccit:ActionForm id="form1" runat="server">
    <input type="hidden" id="_hidClassType" runat="server" />
    <input type="hidden" id="_hidSysDocId" runat="server" />
    <input type="hidden" id="_hisState" runat="server" />
    <input type="hidden" id="_hidCreateId" runat="server" />
    <input type="hidden" id="_hidCreate" runat="server" />
     <asp:LinkButton ID="lnbCallBack" style="display:none" runat="server" 
         onclick="lnbCallBack_Click"></asp:LinkButton>   
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager> 
    <table id="Table1"  class="tableborder" cellpadding="0" cellspacing="0" width="98%" align="center" runat="server">
                           <tr>
                            <td width="15%"  class="pformleft" align="right">上级类别</td>
                            <td class="pformright">
                                <asp:DropDownList ID="ddlUpAddr" CssClass="select" runat="server" Width="90%" ></asp:DropDownList>
                             </td>
                          </tr>
                           <tr>
                            <td width="10%" valign="top" class="pformleft" align="right">类别编号</td>
                            <td class="pformright">
                                  <asp:TextBox ID="txtNumber" CssClass="input" runat="server" Width="90%"></asp:TextBox>
                                 </td>
                          </tr>
                          <tr>
                            <td width="10%" valign="top" class="pformleft" align="right">类别名称</td>
                            <td class="pformright">
                                  <asp:TextBox ID="txtName" CssClass="input" runat="server" Width="90%"></asp:TextBox>
                            </td>
                          </tr> 
                          <tr>
                            <td width="10%"  class="pformleft" align="right">管理权限 <br />
                                 <input type="hidden" id="_hidManageid" runat="server" />
                                 <input type="hidden" id="_hidManageMark" runat="server" />  
                                 <a  id="lnbManage" Runat="server" class="linktext"  
                                    href="javascript:doSelUser('_hidManageid','_hidManageMark','txtManage')">
					                    <img src="../images/toolbar/search.gif" border="0">
				                  </a>
                            </td>
                            <td class="pformright" >
                                    <nobr>
                                        <asp:CheckBox ID="chkManageupaddr" runat="server" Text="继承上级类别管理权限" onclick ="doSelect('0')"></asp:CheckBox>
                                        <asp:CheckBox ID="chkManagelower" runat="server" Text="同步所有下级类别管理权限"></asp:CheckBox> 
                                    </nobr>
                               </td>
                          </tr>
                          <tr>
                            <td width="10%"  class="pformleft" align="right">&nbsp;</td>
                            <td class="pformright" >
                                    <asp:TextBox ID="txtManage" TextMode="MultiLine" Width="98%" Height="90px" 
                                        runat="server" ReadOnly="true" CssClass="inputtext"></asp:TextBox> 
                                 </td>
                          </tr>
                          <tr>
                            <td width="10%"  class="pformleft" align="right">浏览权限<br>
                                     <input type="hidden" id="_hidViewId" runat="server" />
                                     <input type="hidden" id="_hidViewMark" runat="server" />
                                     <a  id="lnbview" Runat="server" class="linktext"  
                                        href="javascript:doSelUser('_hidViewId','_hidViewMark','txtView')">
						                    <img src="../images/toolbar/search.gif" border="0">
					                  </a>
					        </td>
                            <td class="pformright" >
                                    <nobr>
                                         <asp:CheckBox ID="chkViewupaddr" runat="server" Text="继承上级类别浏览权限" onclick ="doSelect('1')"></asp:CheckBox>
                                        <asp:CheckBox ID="chkViewlower" runat="server" Text="同步所有下级类别浏览权限"></asp:CheckBox>  
                                    </nobr>
                             </td>
                          </tr>
                          <tr>
                            <td width="10%"  class="pformleft" align="right">&nbsp;</td>
                            <td class="pformright" >
                                     <asp:TextBox ID="txtView" TextMode="MultiLine" Width="98%" Height="90px" 
                                        runat="server" ReadOnly="true" CssClass="inputtext"></asp:TextBox> 
                            </td>
                          </tr>
                          <tr class="pformstrip" height="20">
                           <td colspan="2" align="center">
                                <input type="button" id="btnSave" value="保存" class="button" onclick="doSave()" />
                               <%-- &nbsp;
                                <input type="button" id="btnSaveCont" value="保存并新增" class="button" onclick="doSave('2')" />
                                &nbsp;
                                <input type="button" id="btnSaveBack" value="保存并返回" class="button" onclick="doSave('3')" />
                                &nbsp;  
                                <input type="button" id="btnBack" value="返回" class="button" onclick="doBack()" />
                                &nbsp;--%>
                            </td>
        </tr>
       </table>
    </ccit:ActionForm>
</body>
</html>
